package com.study.design.pattern.pattern.structural.proxy.staticproxy;

/**
 * @Author: gongsl
 * @Date: 2025-03-19 21:30
 * @description: 支付功能代理类
 */
public class PaymentServiceProxy implements PaymentService {

    private PaymentService paymentService;

    /**
     * 构造方法传入目标对象
     */
    public PaymentServiceProxy(PaymentService paymentService) {
        this.paymentService = paymentService;
    }

    /**
     * 付款
     */
    @Override
    public void pay(String amount) {
        // 在支付前可以加入额外的操作，例如日志记录
        System.out.println("Logging: Payment is about to be processed.");
        // 调用目标对象的实际方法
        paymentService.pay(amount);
        // 在支付后也可以加入额外的操作，例如发送通知
        System.out.println("Logging: Payment has been processed.");
    }
}
